package com.itheima.pattern.memorandum.white_box;


/**
 * 发起者角色
 */
public class GameRole {
    private int vit;//生命力
    private int atk;//攻击力
    private int def;//防御力

    public void initState(){
        this.vit=100;
        this.atk=100;
        this.def=100;
    }

    public void fight(){
        this.vit=0;
        this.atk=0;
        this.def=0;
    }

    public RoleStateMemento saveState(){
        return new RoleStateMemento(vit,atk,def);
    }

    //恢复状态
    public void recoverState(RoleStateMemento roleStateMemento){
        //将备忘录中数据赋值给当前专题
        this.vit=roleStateMemento.getVit();
        this.atk=roleStateMemento.getAtk();
        this.def=roleStateMemento.getDef();
    }

    //展示状态
    public void stateDisplay(){
        System.out.println("生命力："+vit);
        System.out.println("攻击力："+atk);
        System.out.println("防御力："+def);
    }

    public int getVit() {
        return vit;
    }

    public void setVit(int vit) {
        this.vit = vit;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }
}
